const app = getApp()

import {
  config
} from "../../../../js/modules/gloab";
import {
  api
} from '../../../../js/util'

import BasePage from '../../../../js/common/base-page'
import { getStorageSync } from "../../../../js/compatible";

BasePage({
  pageKey: 'aboutApplication',
  validateLogin: false,
  data: {
    logo: '', // 商家图标
    name: '', // 商机名
    version: '', // 小程序版本
    appVersion: '3.3.6', // 当前代码版本
    netLine: '默认线路', // 网络线路
    openId: '', // 用户openId
    infoHeight: 500, // 内容区域高度
    mainColor: api.titleColor || "#e56b14", //主题色
  },
  onLoad () {
    let systemInfo = wx.getSystemInfoSync()
    this.setData({
      infoHeight: systemInfo.windowHeight - 220,
      netLine: app.dns.projectDir||'默认线路'
    })
    this.getApplicationInfo()
  },
  getApplicationInfo () {
    let { proprietorId, proprietor}= app.dns
    let that = this
    //获取批发配置
    config.getWholesaleConfigs(proprietorId, proprietor, "Wholesale", (model) => {
      let logo = model.LogoForMobile || ''
      let name = model.SiteName || ''
      if (logo && /\//.test(logo)) {
        logo = api.imgDomain + logo
      }
      that.setData({
        logo,
        name,
      })
    })
    let accountInfo = wx.getAccountInfoSync()
    let openId = getStorageSync('openid')
    that.setData({
      version: accountInfo.miniProgram.version,
      openId
    })
  },
  setClipboardData (e) {
    let text = e.currentTarget.dataset.text
    wx.setClipboardData({
      data: text
    })
  }
})